Fix types for node16/bundler module resolution strategies #553
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary & motivation
This is a more canonical fix for types than what shipped in v3.0.1, as verified w/ this command:
This fix took a couple days because the combination of quirks in our codebase, quirks in TypeScript, and quirks in available tooling made it difficult to ascertain a fix. Historically, we have shipped types from a
./types
directory with corresponding entrypoint definition files. And since we shipped multiple.d.ts
files, we essentially shipped our types as written. This approach is not compatible with.d.mts
files, since these are not apparently resolved by any TypeScript tooling. As a result, it took some time to find a way to ship a single.d.mts
definition file for ES modules.The
rollup-plugin-dts
Rollup plugin turned out to be the best option after trial and error. It requires minimal changes. As a result of this change, both.d.ts
and.d.mts
declarations are now shipped as single files. However, this is not a breaking change because we have allowed the use of barrel exports from the main TypeScript modules.As a result of this change, we now ship compliant types for
node16
CJS,node16
ESM, andbundler
resolution configurations.node10
support is included for the main@stripe/stripe-js
module. Support for@stripe/stripe-js/pure
is not included in this fix.